package com.ym.goods.service.impl;

import com.ym.goods.dao.GoodsClassEntityMapper;
import com.ym.goods.entity.GoodsClassEntity;
import com.ym.goods.service.GoodsCommonService;
import com.ym.utils.exception.CustomException;
import com.ym.utils.uuid.IdUtils;
import com.ym.utils.uuid.UUID;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GoodsCommonServiceImpl implements GoodsCommonService {

    @Autowired
    private GoodsClassEntityMapper goodsClassEntityMapper;

    @Override
    @GlobalTransactional//全局事务控制
    public GoodsClassEntity addInfor(GoodsClassEntity goodsClassEntity) throws CustomException {
        //goodsClassEntity.setId(IdUtils.fastSimpleUUID());
        int count = goodsClassEntityMapper.insertSelective(goodsClassEntity);
        if (count == 0) {
            throw new CustomException("添加失败");
        }
        return goodsClassEntity;
    }
}
